/**
 * <copyright>
 * </copyright>
 *

 */
package org.eclipse.gittab.gitTabDsl.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.gittab.gitTabDsl.Beat;
import org.eclipse.gittab.gitTabDsl.GitTabDslPackage;
import org.eclipse.gittab.gitTabDsl.GuitarSound;
import org.eclipse.gittab.gitTabDsl.Tab;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Tab</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.eclipse.gittab.gitTabDsl.impl.TabImpl#getName <em>Name</em>}</li>
 *   <li>{@link org.eclipse.gittab.gitTabDsl.impl.TabImpl#getAuthor <em>Author</em>}</li>
 *   <li>{@link org.eclipse.gittab.gitTabDsl.impl.TabImpl#getTempo <em>Tempo</em>}</li>
 *   <li>{@link org.eclipse.gittab.gitTabDsl.impl.TabImpl#getNum <em>Num</em>}</li>
 *   <li>{@link org.eclipse.gittab.gitTabDsl.impl.TabImpl#getDenom <em>Denom</em>}</li>
 *   <li>{@link org.eclipse.gittab.gitTabDsl.impl.TabImpl#getGuitar <em>Guitar</em>}</li>
 *   <li>{@link org.eclipse.gittab.gitTabDsl.impl.TabImpl#getBeat <em>Beat</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TabImpl extends MinimalEObjectImpl.Container implements Tab
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The default value of the '{@link #getAuthor() <em>Author</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAuthor()
   * @generated
   * @ordered
   */
  protected static final String AUTHOR_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getAuthor() <em>Author</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAuthor()
   * @generated
   * @ordered
   */
  protected String author = AUTHOR_EDEFAULT;

  /**
   * The default value of the '{@link #getTempo() <em>Tempo</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTempo()
   * @generated
   * @ordered
   */
  protected static final int TEMPO_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getTempo() <em>Tempo</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTempo()
   * @generated
   * @ordered
   */
  protected int tempo = TEMPO_EDEFAULT;

  /**
   * The default value of the '{@link #getNum() <em>Num</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getNum()
   * @generated
   * @ordered
   */
  protected static final int NUM_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getNum() <em>Num</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getNum()
   * @generated
   * @ordered
   */
  protected int num = NUM_EDEFAULT;

  /**
   * The default value of the '{@link #getDenom() <em>Denom</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDenom()
   * @generated
   * @ordered
   */
  protected static final int DENOM_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getDenom() <em>Denom</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDenom()
   * @generated
   * @ordered
   */
  protected int denom = DENOM_EDEFAULT;

  /**
   * The default value of the '{@link #getGuitar() <em>Guitar</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getGuitar()
   * @generated
   * @ordered
   */
  protected static final GuitarSound GUITAR_EDEFAULT = GuitarSound.NULL;

  /**
   * The cached value of the '{@link #getGuitar() <em>Guitar</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getGuitar()
   * @generated
   * @ordered
   */
  protected GuitarSound guitar = GUITAR_EDEFAULT;

  /**
   * The cached value of the '{@link #getBeat() <em>Beat</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBeat()
   * @generated
   * @ordered
   */
  protected EList<Beat> beat;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected TabImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return GitTabDslPackage.Literals.TAB;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, GitTabDslPackage.TAB__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getAuthor()
  {
    return author;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAuthor(String newAuthor)
  {
    String oldAuthor = author;
    author = newAuthor;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, GitTabDslPackage.TAB__AUTHOR, oldAuthor, author));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getTempo()
  {
    return tempo;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTempo(int newTempo)
  {
    int oldTempo = tempo;
    tempo = newTempo;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, GitTabDslPackage.TAB__TEMPO, oldTempo, tempo));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getNum()
  {
    return num;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setNum(int newNum)
  {
    int oldNum = num;
    num = newNum;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, GitTabDslPackage.TAB__NUM, oldNum, num));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getDenom()
  {
    return denom;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDenom(int newDenom)
  {
    int oldDenom = denom;
    denom = newDenom;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, GitTabDslPackage.TAB__DENOM, oldDenom, denom));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public GuitarSound getGuitar()
  {
    return guitar;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setGuitar(GuitarSound newGuitar)
  {
    GuitarSound oldGuitar = guitar;
    guitar = newGuitar == null ? GUITAR_EDEFAULT : newGuitar;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, GitTabDslPackage.TAB__GUITAR, oldGuitar, guitar));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Beat> getBeat()
  {
    if (beat == null)
    {
      beat = new EObjectContainmentEList<Beat>(Beat.class, this, GitTabDslPackage.TAB__BEAT);
    }
    return beat;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case GitTabDslPackage.TAB__BEAT:
        return ((InternalEList<?>)getBeat()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case GitTabDslPackage.TAB__NAME:
        return getName();
      case GitTabDslPackage.TAB__AUTHOR:
        return getAuthor();
      case GitTabDslPackage.TAB__TEMPO:
        return getTempo();
      case GitTabDslPackage.TAB__NUM:
        return getNum();
      case GitTabDslPackage.TAB__DENOM:
        return getDenom();
      case GitTabDslPackage.TAB__GUITAR:
        return getGuitar();
      case GitTabDslPackage.TAB__BEAT:
        return getBeat();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case GitTabDslPackage.TAB__NAME:
        setName((String)newValue);
        return;
      case GitTabDslPackage.TAB__AUTHOR:
        setAuthor((String)newValue);
        return;
      case GitTabDslPackage.TAB__TEMPO:
        setTempo((Integer)newValue);
        return;
      case GitTabDslPackage.TAB__NUM:
        setNum((Integer)newValue);
        return;
      case GitTabDslPackage.TAB__DENOM:
        setDenom((Integer)newValue);
        return;
      case GitTabDslPackage.TAB__GUITAR:
        setGuitar((GuitarSound)newValue);
        return;
      case GitTabDslPackage.TAB__BEAT:
        getBeat().clear();
        getBeat().addAll((Collection<? extends Beat>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case GitTabDslPackage.TAB__NAME:
        setName(NAME_EDEFAULT);
        return;
      case GitTabDslPackage.TAB__AUTHOR:
        setAuthor(AUTHOR_EDEFAULT);
        return;
      case GitTabDslPackage.TAB__TEMPO:
        setTempo(TEMPO_EDEFAULT);
        return;
      case GitTabDslPackage.TAB__NUM:
        setNum(NUM_EDEFAULT);
        return;
      case GitTabDslPackage.TAB__DENOM:
        setDenom(DENOM_EDEFAULT);
        return;
      case GitTabDslPackage.TAB__GUITAR:
        setGuitar(GUITAR_EDEFAULT);
        return;
      case GitTabDslPackage.TAB__BEAT:
        getBeat().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case GitTabDslPackage.TAB__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case GitTabDslPackage.TAB__AUTHOR:
        return AUTHOR_EDEFAULT == null ? author != null : !AUTHOR_EDEFAULT.equals(author);
      case GitTabDslPackage.TAB__TEMPO:
        return tempo != TEMPO_EDEFAULT;
      case GitTabDslPackage.TAB__NUM:
        return num != NUM_EDEFAULT;
      case GitTabDslPackage.TAB__DENOM:
        return denom != DENOM_EDEFAULT;
      case GitTabDslPackage.TAB__GUITAR:
        return guitar != GUITAR_EDEFAULT;
      case GitTabDslPackage.TAB__BEAT:
        return beat != null && !beat.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(", author: ");
    result.append(author);
    result.append(", tempo: ");
    result.append(tempo);
    result.append(", num: ");
    result.append(num);
    result.append(", denom: ");
    result.append(denom);
    result.append(", guitar: ");
    result.append(guitar);
    result.append(')');
    return result.toString();
  }

} //TabImpl
